<template>
    <div class="demo">
        <h2>学校名称：{{name}}</h2>
        <h2>地址：{{address}}</h2>
	</div>
</template>

<script>
    export default {
        name:'School',
        data(){
           return {
            name:'广师大',
            address:'广州天河区'
           }
        },
        mounted(){
            // 绑定自定义事件
            this.$bus.$on('hello',(data) => {
                console.log('School组件接收到了数据：',data)
            })
        },
        beforeDestroy(){
            this.$bus.$off('hello') // 解绑事件
        }
    }
</script>
<style scoped>
    .demo{
        background-color: green;
    }
</style>